package com.liu.sunnyday.controller;

import com.liu.sunnyday.entity.Result;
import com.liu.sunnyday.exception.SunnydayException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * chance！Time
 *
 * @author liuqian
 * @date 2022-06-12 15:53
 *
 *添加异常处理类
 */
@RestControllerAdvice
public class HealExceptionAdvice {

    /*
    * z自定义异常处理
    * */
    @ExceptionHandler(SunnydayException.class)
    public Result handleSunnydayException(SunnydayException he){
        System.out.println("异常");
        return new Result(false,he.getMessage());
    }
    /*
     * z自定义异常处理
     * */
//    @ExceptionHandler(SunnydayGroupException.class)
//    public Result handleSunnydayGroupException(SunnydayGroupException he){
//
//        return new Result(false,he.getMessage());
//    }


    /*所有未知异常*/
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception he){
        return new Result(false,"发生未知错误，操作失败，请联系管理员");
    }
}
